from launch import LaunchDescription
from launch_ros.actions import Node
from ament_index_python.packages import get_package_share_directory
from launch_ros.substitutions import FindPackageShare
import os

def generate_launch_description():
    # 直接获取绝对路径
    config_file = os.path.join(
        get_package_share_directory('ftr3_driver'),
        'config',
        'ftr3_config.yaml'
    )
    print("Config file path:", config_file)
    
    # 定义FTR3驱动节点
    ftr3_node = Node(
        package='ftr3_driver',
        executable='ftr3_node',
        name='ftr3_node',
        output='screen',
        parameters=[
            config_file  # 加载配置文件
        ],
        # 可选：如果需要，可以在这里添加额外的参数覆盖配置文件中的值
        # arguments=['--ros-args', '-p', 'can_interface:=can1']
    )
    
    return LaunchDescription([
        ftr3_node
    ])
    